package com.woniuxy.bankb.controller;

import com.woniuxy.bankb.service.BankBService;
import com.woniuxy.commons.entity.Bank;
import com.woniuxy.commons.util.ResponseResult;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/bankb")
public class BankBController {

    @Resource
    private BankBService bankBService;

    @Transactional
    @GetMapping("/update/{id}/{money}")
    public ResponseResult<String> update(@PathVariable(value = "id")int id, @PathVariable(value = "money")int money){
        Bank bank = new Bank(id,money,null);
        int result = bankBService.update(bank);
        ResponseResult<String> result1 = new ResponseResult<>();
        result1.setCode(200);
        result1.setMessage("fail");
        if(result >= 1){
            result1.setMessage("success");
        }
        return result1;
    }
}
